from functools import wraps


def single_ton(cls):
    _instance = {}

    @wraps(cls)
    def single(*args, **kwargs):
        if cls not in _instance:
            _instance[cls] = cls(*args, **kwargs)
        return _instance[cls]

    return single


@single_ton
class SingleTon(object):
    val = 123

    def __init__(self, a):
        self.a = a

    def get_value(self):
        return self.a


if __name__ == '__main__':
    s = SingleTon(1)
    t = SingleTon(2)
    print(s is t)
    print(s.a, t.a)
    print(s.val, t.val)
    print(s.get_value(), t.get_value())
'''
True
1 1
123 123
1 1
'''